#region Using directives
using System;
using SharpWind.Resources;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
using Microsoft.Xna.Framework.Content;
using SharpWind.Helpers;
#endregion

namespace SharpWind.Graphics.Models
{
	public abstract class BaseModel : Resource
	{
		#region Fields

		private Model xnaModel = null;

		private string name = string.Empty;

		#endregion

		#region Constructors

		public BaseModel( string name )
		{
			if( string.IsNullOrEmpty( name ) )
			{
				throw new ArgumentNullException( "name" );
			}

			this.name = Path.GetFileNameWithoutExtension( name );
		}

		#endregion

		#region Methods

		internal override void LoadContent( ContentManager contentManager )
		{
			this.xnaModel = contentManager.Load<Model>( Path.Combine( Directories.Models, name ) );
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				this.xnaModel = null;
			}
		}

		#endregion

		#region Properties

		public string Name
		{
			get
			{
				return this.name;
			}
		}

		internal Model XnaModel
		{
			get
			{
				return this.xnaModel;
			}
		}

		#endregion
	}
}
